package com.zhongzhi.controller;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhongzhi.service.StationService;
import com.zhongzhi.springboot.pojo.Computers;
import com.zhongzhi.springboot.pojo.Station;
import com.zhongzhi.util.Bo;
import com.zhongzhi.util.JsonResult;


/**
 * 通道业务层
 * @author Administrator
 *
 */

@RestController
@RequestMapping("/station/")
public class StationController {

	@Autowired
	private StationService stationService;

	//1:增加通道
	@RequestMapping("insert")
	public JsonResult insert(Station station) {
		Bo bo = stationService.insert(station);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//2:修改通道
	@RequestMapping("update")
	public JsonResult update(Station station) {
		Bo bo = stationService.update(station);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//3:删除通道(如果通道下面有测试数据,则不能删除)
	@RequestMapping("delete")
	public JsonResult delete(Integer id) {
		Bo bo = stationService.delete(id);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//4:查询全部通道
	@RequestMapping("select")
	public JsonResult select(Integer pages,Integer line) {
		Bo bo = stationService.select(pages,line);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//5:查询全部通道总数
	@RequestMapping("selectSize")
	public JsonResult selectSize() {
		Bo bo = stationService.selectSize();
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//6:查询通道(根据id查询)
	@RequestMapping("selectById")
	public JsonResult selectById(Integer id) {
		Bo bo = stationService.selectById(id);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//根据plcid查询通道
	@RequestMapping("selectByequipmentId")
	public JsonResult selectByequipmentId(Integer equipmentId) {
		Bo bo = stationService.selectByequipmentId(equipmentId);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//根据plcid数组查询通道
	@RequestMapping("selectByequipmentIds")
	public JsonResult selectByequipmentIds(Integer... equipmentIds) {
		Bo bo = stationService.selectByequipmentIds(equipmentIds);
		return  new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//8:增加计算机
	@RequestMapping("webinsert")
	public JsonResult webinsert(Station station) {
		Bo bo = stationService.webinsert(station);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//9:修改计算机
	@RequestMapping("webupdate")
	public JsonResult webupdate(Station station) {
		Bo bo = stationService.webupdate(station);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//10:删除计算机(如果计算机有者通道,则不能删除)
	@RequestMapping("webdelete")
	public JsonResult webdelete(Integer id) {
		Bo bo = stationService.webdelete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//11:查询全部计算机
	@RequestMapping("webselect")
	public JsonResult webselect() {
		Bo bo = stationService.webselect();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
}
